﻿// 使用Sobel、Canny算子进行边缘检测
//

#include "pch.h"
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;

int main()
{
	Mat image = imread("E:\\VC_project\\figure\\lena.jpg");
	Mat gray, imageSobel, imageCanny;

	//图像灰度化处理
	cvtColor(image, gray, COLOR_BGR2GRAY);
	imshow("原始图像", image);
	imshow("灰度处理", gray);

	//使用Sobel算子进行边缘检测
	Sobel(gray, imageSobel, -1, 0, 1, 3);
	imshow("Sobel边缘检测", imageSobel);
	

	//使用Canny算子进行边缘检测
	Canny(gray, imageCanny, 80, 200, 3);
	imshow("Canny边缘检测", imageCanny);
	waitKey();
}

